package com;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JPanel;

/**
 *
 * @author alrz
 */
public class Figure extends JPanel
{
    private int up;
    private int down;
    private int left;
    private int right;
    private boolean pressed;

    public Figure( int up, int down, int left, int right)
    {
        super();
        this.up = up;
        this.down = down;
        this.left = left;
        this.right = right;
        this.pressed = false;
    }
    @Override
    public void paint(Graphics g)
    {      
     
        this.createTriangle(g, new Point(0,0), new Point(this.getWidth(),0), new Point(this.getWidth()/2, this.getHeight()/2), this.up);
        g.drawImage(Icons.getIconNumber(up), (int)(this.getWidth()/2.5), this.getHeight()/10, this);
       
        this.createTriangle(g, new Point(0,0), new Point(this.getWidth()/2, this.getHeight()/2), new Point(0,this.getHeight()), this.left);
        g.drawImage(Icons.getIconNumber(this.left), 10, 37, this);
       
        this.createTriangle(g, new Point(0,this.getHeight()), new Point(this.getWidth(),this.getHeight()),new Point(this.getWidth()/2, this.getHeight()/2),this.down);
        g.drawImage(Icons.getIconNumber(this.down), (int)(this.getWidth()/2.6), 70, this);
       
        this.createTriangle(g,new Point(this.getWidth(),this.getHeight()), new Point(this.getWidth(),0), new Point(this.getWidth()/2, this.getHeight()/2),this.right);
        g.drawImage(Icons.getIconNumber(this.right), 70, 37, this);
       
        g.setColor(Color.BLACK);
        g.drawLine(0, 0,this.getWidth(), this.getHeight());
        g.drawLine(0,  this.getHeight(),this.getWidth(),0);
        g.drawRect(0, 0, this.getWidth(), this.getHeight());
       
    }
   
    public void createTriangle(Graphics g, Point p1,Point p2, Point p3, int value)
    {
        Polygon polygon = new Polygon();
        polygon.reset();
        polygon.addPoint(p1.x, p1.y);
        polygon.addPoint(p2.x, p2.y);
        polygon.addPoint(p3.x, p3.y);
        g.setColor(getColor(value));
        g.fillPolygon(polygon);
    }
    public Color getColor(int value)
    {
        if(value == 1)
        {
            return Color.PINK;
        }
        if(value == 2)
        {
            return Color.RED;
        }
        if(value == 3)
        {
            return Color.ORANGE;
        }
        if(value == 4)
        {
            return Color.YELLOW;
        }
        if(value == 5)
        {
            return Color.GREEN;
        }
        if(value == 6)
        {
            return Color.BLUE;
        }
        if(value == 7)
        {
            return Color.MAGENTA;
        }
        if(value == 8)
        {
            return Color.GRAY;
        }
        if(value == 9)
        {
            return Color.WHITE;
        }
        return Color.BLACK;
    }

    public int getDown() {
        return down;
    }

    public void setDown(int down) {
        this.down = down;
    }

    public int getLeft() {
        return left;
    }

    public void setLeft(int left) {
        this.left = left;
    }

    public boolean isPressed() {
        return pressed;
    }

    public void setPressed(boolean pressed) {
        this.pressed = pressed;
    }

    public int getRight() {
        return right;
    }

    public void setRight(int right) {
        this.right = right;
    }

    public int getUp() {
        return up;
    }

    public void setUp(int up) {
        this.up = up;
    }

    void imprimir() {
        System.out.println(" "+this.up);
        System.out.println(this.left+" "+this.right);
        System.out.println(" "+this.down);
    }
}

